import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom'; // 如果您在使用 React Router
import { useDispatch } from 'react-redux';
import { updateCanvasState } from '../../store/index'; // 添加一个 action 来更新画布状态
const Fx=()=>{
     const location = useLocation();
  const dispatch = useDispatch();

   useEffect(() => {
    const params = new URLSearchParams(location.search);
    const state = params.get('state');
    
    if (state) {
      const decodedState = decodeURIComponent(state);
      const canvasState = JSON.parse(decodedState);
      
      // 更新画布状态
      dispatch(updateCanvasState(canvasState)); // 确保在 reducer 中定义此 action
    }
  }, [location, dispatch]);
    return (
         <div>
        <h2>画布预览</h2>
        {/* 这里可以放置呈现图画的组件 */}
        </div>
    )
}
export default Fx